//
//  SKUDetailFourCellCell.m
//  Tang
//
//  Created by 352324497@qq.com on 15/12/8.
//  Copyright © 2015年 352324497@qq.com. All rights reserved.
//

#import "SKUDetailFourCellCell.h"

@implementation SKUDetailFourCellCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        CGFloat width = frame.size.width;
        self.photoImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, width, width)];
//        self.photoImageView.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_photoImageView];
        
        self.backView = [[UIView alloc]initWithFrame:CGRectMake(0, width, width, 70 * Kx6)];
        self.backView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_backView];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 * Kx6, 10 * Kx6, width - 20 * Kx6, 30 * Kx6)];
//        self.titleLabel.backgroundColor = [UIColor redColor];
        self.titleLabel.textColor = [UIColor darkGrayColor];
        self.titleLabel.font = [UIFont systemFontOfSize: 14 * Kx6];
        [self.backView addSubview:_titleLabel];
        
        self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 * Kx6, 40 * Kx6, width / 2, 20 * Kx6)];
//        self.priceLabel.backgroundColor = [UIColor cyanColor];
        self.priceLabel.textColor = [UIColor orangeColor];
        self.priceLabel.font = [UIFont systemFontOfSize:12  * Kx6];
        [self.backView addSubview:_priceLabel];
        
        
        self.likeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        self.likeButton.frame = CGRectMake(width - 30 * Kx6, 40 * Kx6, 20 * Kx6, 20 * Kx6);
//        self.likeButton.backgroundColor = [UIColor greenColor];
        [self.likeButton setImage:[UIImage imageNamed:@"like"] forState:(UIControlStateNormal)];
        [self.likeButton setImage:[UIImage imageNamed:@"islike"] forState:(UIControlStateSelected)];
        [self.backView addSubview:_likeButton];
    }
    return self;
}

-(void)setModel:(SKUDetailFourModel *)model
{
    _model = model;
    [self.photoImageView sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:[UIImage imageNamed:@"PC"]];
    self.titleLabel.text = model.title;
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@", model.price];
}
@end
